package org.glut.service;

import org.glut.bean.User;
import org.glut.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.UUID;

@Service
public class UserServer {
    @Autowired
    private UserDao userDao;

    public User getUserByname(String name ){
       return userDao.getUserByname(name);
    }
    public ArrayList<User> getAllUsers(){
       return userDao.getAllUsers();
    }

//    public boolean updateUser(String username,String password){
//       return userDao.updateUser(username, password);
//    }
    public boolean updateUser(User user){
       return userDao.updateUser(user);
    }

    public boolean deleteUserByname(String username){
       return userDao.deleteUserByName(username);
    }

    public boolean addUser(User user){
        String id = UUID.randomUUID().toString().replaceAll("-", "");
        user.setId(id);
        user.setRole("");
        return userDao.addUser(user);
    }

}
